#include "BaseNetwork.h"

void Network_setName(Network *t, const char *name)
{
    strcpy(t->name, name);
}

void Network_setAddress(Network *t, const char *address)
{
    strcpy(t->address, address);
}

void Network_setPort(Network *t, int port)
{
    t->port = port;
}

void Network_SendSync(Network *t, const char *data, size_t data_len)
{
    printf("[%s:%d] [%s] SendSync, Data:[%s], Size:[%d]\n", __FUNCTION__, __LINE__, t->name, data, data_len);
}

void Network_SendAsync(Network *t, const char *data, size_t data_len)
{
    printf("[%s:%d] [%s] SendAsync, Data:[%s], Size:[%d]\n", __FUNCTION__, __LINE__, t->name, data, data_len);
}

size_t Network_RecvSync(Network *t, char *data)
{
    size_t recv_len = 0;
    printf("[%s:%d] [%s] Network_RecvSync\n", __FUNCTION__, __LINE__, t->name);

    return recv_len;
}

size_t Network_RecvAsync(Network *t, char *data)
{
    size_t recv_len = 0;
    printf("[%s:%d] [%s] Network_RecvAsync\n", __FUNCTION__, __LINE__, t->name);

    return recv_len;
}

void Network_Init(Network *t, const char *name, const char *address, int port)
{
    printf("[%s:%d] Init for Network. Name:[%s], Address:[%s], Port:[%d]\n", __FUNCTION__, __LINE__, name, address, port);

    t->setName(t, name);
    t->setAddress(t, address);
    t->setPort(t, port);
}

ABS_CTOR(Network)
FUNCTION_SETTING(setName, Network_setName);
FUNCTION_SETTING(setAddress, Network_setAddress);
FUNCTION_SETTING(setPort, Network_setPort);
FUNCTION_SETTING(SendSync, Network_SendSync);
FUNCTION_SETTING(SendAsync, Network_SendAsync);
FUNCTION_SETTING(RecvSync, Network_RecvSync);
FUNCTION_SETTING(RecvAsync, Network_RecvAsync);
FUNCTION_SETTING(Init, Network_Init);
END_ABS_CTOR
